package com.xhcl.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xhcl.common.annotation.Log;
import com.xhcl.common.enums.BusinessType;
import com.xhcl.system.domain.TSrhsKmye;
import com.xhcl.system.service.ITSrhsKmyeService;
import com.xhcl.common.core.controller.BaseController;
import com.xhcl.common.core.domain.AjaxResult;
import com.xhcl.framework.uitls.poi.ExcelUtil;
import com.xhcl.framework.shiro.util.ShiroUtils;
import com.xhcl.common.core.page.TableDataInfo;

/**
 * 科目余额Controller
 * 
 * @author xhcl
 * @date 2020-09-03
 */
@Controller
@RequestMapping("/system/nzjz")
public class TSrhsNzjzController extends BaseController
{
    private String prefix = "system/nzjz";

    @Autowired
    private ITSrhsKmyeService tSrhsKmyeService;

    @RequiresPermissions("system:nzjz:view")
    @GetMapping()
    public String nzjz()
    {
        return prefix + "/nzjz";
    }

    /**
     * 查询科目余额列表
     */
    @RequiresPermissions("system:nzjz:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list()
    {
        startPage();
        List<TSrhsKmye> list = tSrhsKmyeService.selectTSrhsKmyeForNzjzList();
        return getDataTable(list);
    }

    /**
     * 导出科目余额列表
     */
    @RequiresPermissions("system:nzjz:export")
    @Log(title = "科目余额", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export()
    {
        List<TSrhsKmye> list = tSrhsKmyeService.selectTSrhsKmyeForNzjzList();
        ExcelUtil<TSrhsKmye> util = new ExcelUtil<TSrhsKmye>(TSrhsKmye.class);
        return util.exportExcel(list, "nzjz");
    }

    @RequiresPermissions("system:nzjz:nzzz")
    @Log(title = "年终转账", businessType = BusinessType.UPDATE)
    @PostMapping("/doNzzz")
    @ResponseBody
    public AjaxResult doNzzz(@RequestBody List<TSrhsKmye> list)
    {   
    	tSrhsKmyeService.doNzzz(list,  ShiroUtils.getSysUser().getLoginName());
        return AjaxResult.success();
    }

    
     
}
